// pages/function/sub/upload-index.js
const APP = getApp();
//常量
const ACTIONS_LIST_DATA = [
  [
    {
      title: '单项上传',
      icon: '/pages/res/common/icon_list_item2.png',
      link: '/pages/function/upload/upload-img',
      open_type:'navigate',
      extra_data:{}
    },
    {
      title: '多项上传',
      icon: '/pages/res/common/icon_list_item2.png',
      link: '/pages/function/upload/upload-multi',
      open_type:'navigate',
      extra_data:{}
    },
    {
        title: '多项上传（编辑）',
        icon: '/pages/res/common/icon_list_item2.png',
        link: '/pages/function/upload/upload-multi?tid=1',
        open_type:'navigate',
        extra_data:{}
      },
    {
        title: '批量多项上传',
        icon: '/pages/res/common/icon_list_item2.png',
        link: '/pages/function/upload/upload-batch',
        open_type:'navigate',
        extra_data:{}
      },
    {
      title: '批量多项上传（编辑）',
      icon: '/pages/res/common/icon_list_item2.png',
      link: '/pages/function/upload/upload-batch?tid=1',
      open_type:'navigate',
      extra_data:{}
    },
    {
      title: '单项显示',
      icon: '/pages/res/common/icon_list_item1.png',
      link: '/pages/function/upload/display-img',
      open_type:'navigate',
      extra_data:{}
    },
    {
        title: '多项显示',
        icon: '/pages/res/common/icon_list_item1.png',
        link: '/pages/function/upload/display-multi',
        open_type:'navigate',
        extra_data:{}
    },
    {
        title: '批量多项显示',
        icon: '/pages/res/common/icon_list_item1.png',
        link: '/pages/function/upload/display-batch',
        open_type:'navigate',
        extra_data:{}
    },
  ],
];

Page({

  /**
   * 页面的初始数据
   */
  data: {
      //固定参数
      //分页变量
      //逻辑变量
      dataActionList:ACTIONS_LIST_DATA
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  },

  /**
   * 逻辑区域
   */

   //点击功能模块
   clickAction:function(event){
    let _this = this,dataset = event.currentTarget.dataset;
    let actionInfo = _this.data.dataActionList[dataset.pidx][dataset.idx];
    if(actionInfo.open_type == 'switchTab'){
      wx.setStorage({
        data: JSON.stringify(actionInfo.extra_data),
        key: 'nav_flag',
        success:function(res){
          wx.switchTab({
            url: actionInfo.link,
          });
        }
      });
    }else if(actionInfo.open_type == 'navigate'){
      wx.navigateTo({
        url: actionInfo.link+'?param='+APP.apptool.encodeJsonStr(actionInfo.extra_data),
      });
      }else{
        wx.navigateTo({
          url: actionInfo.link+'?param='+APP.apptool.encodeJsonStr(actionInfo.extra_data),
        });
      }
    },
})